rm(list = ls())
set.seed(1111)
library(MatchIt)
library(dplyr)
library(ggplot2)
library(haven)
library(stargazer)
library(tableone)
library(Hmisc)
library(cem)
library(Matching)
library(car)
library(Zelig)
library(RColorBrewer)
library(arm)
setwd("~/Dropbox/AttorneyMainData")
data <- read_dta("Attorney.dta")
data$hysLaw <- car::recode(data$SchoolLawyerArgue,"'Harvard'=1;'Yale'=1;'Stanford'=1;'Columbia'=1;'Chicago'=1;else=0")
data$T14 <- car::recode(data$SchoolLawyerArgue,"'Columbia'=1;'Cornell'=1;'Duke'=1;'Georgetown'=1;'Harvard'=1;'NYU'=1;'Northwestern'=1;'Stanford'=1;'California-Berkeley'=1;'Chicago'=1;'Michigan'=1;'Penn'=1;'Virginia'=1;'Yale'=1;else=0")
data$demPres <- car::recode(data$SGOrals,"'McCree'=1;'Lee'=0;'(Acting) Fried'=0;'Fried'=0;'(Acting) Bryson'=0;'Starr'=0;'Days'=1;'(Acting) Dellinger'=1;'Waxman'=1;'(Acting) Underwood'=0; 'Olson'=0;'(Acting) Clement'=0;'Clement'=0;'Garre'=0;'(Acting) Kneedler'=1;'Kagan'=1;'(Acting) Katyal'=1;'Verrilli'=1;'(Acting) Gershengorn'=1;'(Acting) Francisco'=1;'(Acting) Wall'=1; 'Francisco'=1")
##Bryson was acting for both Bush 1 and Reagan
data$demPres[data$SGOrals=="(Acting) Bryson" & data$term=="1992"] <- 1
data$SGOralsCollapseF <- as.factor(data$SGOralsCollapse)
data$justiceNameF <- as.factor(data$justiceName)
data$ActingSGOrals <- as.numeric(factor(data$ActingSGOrals, ordered=F))-1
data$TopLawSchool <- as.numeric(factor(data$TopLawSchool, ordered=F))-1
data$DCFirm <- as.numeric(factor(data$DCFirm, ordered=F))-1
data$ClerkDummy <- as.numeric(factor(data$ClerkDummy, ordered=F))-1
data$OppPetOrResp <- as.numeric(factor(data$OppPetOrResp, ordered=F))-1
data$CriminalDummy <- as.numeric(factor(data$CriminalDummy, ordered=F))-1
data$CivLibDummy <- as.numeric(factor(data$CivLibDummy, ordered=F))-1
data$EconDummy <- as.numeric(factor(data$EconDummy, ordered=F))-1
data$Acela <- as.numeric(factor(data$Acela, ordered=F))-1
data$LawyerArgueOSG <- as.numeric(factor(data$LawyerArgueOSG, ordered=F))-1
data$GenderLawyerArgue <- as.numeric(factor(data$GenderLawyerArgue, ordered=F))-1
data$RaceLawyerArgue <- as.numeric(factor(data$RaceLawyerArgue, ordered=F))-1
data$IdeologyOppCounsel <- as.numeric(factor(data$IdeologyOppCounsel, ordered=F))-1
ctLevel <- subset(data, ct_level==1)
summary(data)
dim(data)


###Manuscript, Table 1
summary(ctLevel$WhoWon)
sd(ctLevel$WhoWon,na.rm=T)
summary(data$JVote)
sd(data$JVote,na.rm=T)
summary(ctLevel$PriorOral)
sd(ctLevel$PriorOral,na.rm=T)
summary(ctLevel$hysLaw)
sd(ctLevel$hysLaw,na.rm=T)
summary(ctLevel$DCFirm)
sd(ctLevel$DCFirm,na.rm=T)
summary(ctLevel$ClerkDummy)
sd(ctLevel$ClerkDummy,na.rm=T)
summary(ctLevel$Burger)
sd(ctLevel$Burger,na.rm=T)
summary(ctLevel$Rehnquist)
sd(ctLevel$Rehnquist,na.rm=T)
summary(ctLevel$Roberts)
sd(ctLevel$Roberts,na.rm=T)
summary(ctLevel$OppPetOrResp)
sd(ctLevel$OppPetOrResp,na.rm=T)
summary(ctLevel$IdeologyOppCounsel)
sd(ctLevel$IdeologyOppCounsel,na.rm=T)
summary(ctLevel$demPres)
sd(ctLevel$demPres,na.rm=T)

###SI, Figure A1
summary(data$MQCompatability)
sd(data$MQCompatability,na.rm=T)
summary(data$MQTerm)
sd(data$MQTerm,na.rm=T)
summary(ctLevel$lcConservative)
sd(ctLevel$lcConservative,na.rm=T)
summary(ctLevel$CriminalDummy)
sd(ctLevel$CriminalDummy,na.rm=T)
summary(ctLevel$CivLibDummy)
sd(ctLevel$CivLibDummy,na.rm=T)
summary(ctLevel$EconDummy)
sd(ctLevel$EconDummy,na.rm=T)
summary(ctLevel$T14)
sd(ctLevel$T14,na.rm=T)
summary(ctLevel$LawyerArgueOSG)
sd(ctLevel$LawyerArgueOSG,na.rm=T)

###SI, Table A2
t.test(ctLevel$hysLaw~ctLevel$PriorOral)
t.test(ctLevel$DCFirm~ctLevel$PriorOral)
t.test(ctLevel$ClerkDummy~ctLevel$PriorOral)
t.test(ctLevel$Burger~ctLevel$PriorOral)
t.test(ctLevel$Rehnquist~ctLevel$PriorOral)
t.test(ctLevel$Roberts~ctLevel$PriorOral)
t.test(ctLevel$OppPetOrResp~ctLevel$PriorOral)
t.test(ctLevel$IdeologyOppCounsel~ctLevel$PriorOral)
t.test(ctLevel$demPres~ctLevel$PriorOral)
t.test(ctLevel$MQCompatability~ctLevel$PriorOral)
t.test(ctLevel$MQTerm~ctLevel$PriorOral)
t.test(ctLevel$lcConservative~ctLevel$PriorOral)
t.test(ctLevel$CriminalDummy~ctLevel$PriorOral)
t.test(ctLevel$CivLibDummy~ctLevel$PriorOral)
t.test(ctLevel$EconDummy~ctLevel$PriorOral)
t.test(ctLevel$T14~ctLevel$PriorOral)
t.test(ctLevel$LawyerArgueOSG~ctLevel$PriorOral)



